package cn.ihrm.sass;

import cn.utils.IdWorker;
import cn.utils.JWTUtils;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter;

/**
 * @author Mxb
 * @version 1.0
 * @date 2020/7/1 17:18
 */
// 配置springboot的包扫描
@SpringBootApplication(scanBasePackages = "cn")

//配置jpa注解的扫描 就是扫描实体类
@EntityScan("cn.ihrm.sass.entity.system")
public class SystemApplication {
    public static void main(String[] args) {
        SpringApplication.run(SystemApplication.class, args);
    }

    /**
     * 将IdWorker对象放入到 容器中
     * @return
     */
    @Bean
    public IdWorker idWorker() {
        return new IdWorker(1, 1);
    }

    /**
     * 将 对象放入到容器中
     * @return
     */
    @Bean
    public JWTUtils jwtUtils(){
        return new JWTUtils();
    }

    /**
     * 解决jpa的经典问题 no session
     * @return
     */
    @Bean
    public OpenEntityManagerInViewFilter openEntityManagerInViewFilter() {
        return new OpenEntityManagerInViewFilter();
    }
}
